# -*- coding: utf-8 -*-
# @Time    :2021/1/17 23:23
# @Author  :robot_zsj
# @File    :manager.py.py
from application import app, db, manager,scheduler
from flask_script import Server,Command
from www import *

# web server
manager.add_command("runserver", Server(host='0.0.0.0', port=81, use_debugger=True, use_reloader=True))

@Command
def create_all():
    from application import db
    from common.models.user import User
    db.create_all()

manager.add_command("create_all", create_all)

def aps_test():
    import datetime
    print(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S"))


def main():
    app.apscheduler.add_job(func=aps_test,trigger="cron", second="*/5", id="aps_test")
    scheduler.start()
    manager.run()


if __name__ == "__main__":
    try:
        import sys

        sys.exit(main())
    except Exception as e:
        import traceback

        traceback.print_exc()